<?php

class Form_LoanForm extends Form_Custom_General {

    public function init() {
        $ln_id = $this->createElement('hidden', 'ln_id')
                ->addFilters(array(
                    new Zend_Filter_StringTrim(),
                ))
                ->setAttribs(Array("size" => "60"));
        $this->addElement($ln_id);

        $ln_name = $this->createElement('text', 'ln_name')
                ->setRequired(TRUE)
                ->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => "Please enter name")))
                ->addFilters(array(
                    new Zend_Filter_StringTrim(),
                ))
                ->setAttribs(Array("size" => "60", "class" => "span6", "placeholder" => "Name"));
        $this->addElement($ln_name);
        
        
        $ln_cus_id = $this->createElement('select', 'ln_cus_id')
                ->setRequired(TRUE)
                ->addFilters(array(
                    new Zend_Filter_StringTrim(),
                    new Zend_Filter_StringToLower()
                ))
                ->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => "Please select customer")));
        $this->addElement($ln_cus_id);
        
        
        
        $ln_ag_id = $this->createElement('select', 'ln_ag_id')
                ->setRequired(TRUE)
                ->addFilters(array(
                    new Zend_Filter_StringTrim(),
                    new Zend_Filter_StringToLower()
                ))
                ->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => "Please select agent")));
        $this->addElement($ln_ag_id);
        
        $digitValidator = new Zend_Validate_Float();
        $digitValidator->setMessage('Please enter valid amount.');
        
        $ln_amount = $this->createElement('text', 'ln_amount')
                ->setRequired(TRUE)
                ->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => "Please enter amount")))
                ->addValidator($digitValidator, true)
                ->addFilters(array(
                    new Zend_Filter_StringTrim(),
                ))
                ->setAttribs(Array("size" => "60", "class" => "span6", "placeholder" => "Amount"));
        $this->addElement($ln_amount);
        
        
        $digitValidator1 = new Zend_Validate_Float();
        $digitValidator1->setMessage('Please enter valid Advance amount.');
        $ln_advance = $this->createElement('text', 'ln_advance')
                 ->setRequired(TRUE)
                ->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => "Please enter advance amount")))
                ->addValidator($digitValidator1, true)
                ->addFilters(array(
                    new Zend_Filter_StringTrim(),
                ))
                ->setAttribs(Array("size" => "60", "class" => "span6", "placeholder" => "Advance Amount"));
        $this->addElement($ln_advance);
        
        $ln_startdate = $this->createElement('text', 'ln_startdate')
                 ->setRequired(TRUE)
                ->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => "Please enter startdate")))
                ->addFilters(array(
                    new Zend_Filter_StringTrim(),
                ))
                ->setAttribs(Array("size" => "60", "class" => "span6 datepicker", 'readonly' => 'readonly', "placeholder" => "Start Date"));
        $this->addElement($ln_startdate);
        
        $ln_enddate = $this->createElement('text', 'ln_enddate')
                 ->setRequired(TRUE)
                ->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => "Please enter enddate")))
                ->addFilters(array(
                    new Zend_Filter_StringTrim(),
                ))
                ->setAttribs(Array("size" => "60", "class" => "span6 datepicker", "readonly" => 'readonly', "placeholder" => "End Date"));
        $this->addElement($ln_enddate);
        
        
        $ln_guarantor_name = $this->createElement('text', 'ln_guarantor_name')
                 #->setRequired(TRUE)
                #->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => "Please enter enddate")))
                ->addFilters(array(
                    new Zend_Filter_StringTrim(),
                ))
                ->setAttribs(Array("size" => "60", "class" => "span6",  "placeholder" => "Guarantor Name"));
        $this->addElement($ln_guarantor_name);
        
        $ln_guarantor_address = $this->createElement('textarea', 'ln_guarantor_address')
                #->setRequired(TRUE)
                #->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => "Please enter enddate")))
                ->addFilters(array(
                    new Zend_Filter_StringTrim(),
                ))
                ->setAttribs(Array("size" => "60",  "rows" => "3", "cols" => "10", "class" => "span6",  "placeholder" => "Guarantor Address "));
        $this->addElement($ln_guarantor_address);
        
        $ln_guarantor_mobile = $this->createElement('text', 'ln_guarantor_mobile')
                #->setRequired(TRUE)
                #->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => "Please enter enddate")))
                ->addFilters(array(
                    new Zend_Filter_StringTrim(),
                ))
                ->setAttribs(Array("size" => "60", "class" => "span6",  "placeholder" => "Guarantor Mobile"));
        $this->addElement($ln_guarantor_mobile);

        $ln_note = $this->createElement('textarea', 'ln_note')
                 #->setRequired(TRUE)
                #->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => "Please enter enddate")))
                ->addFilters(array(
                    new Zend_Filter_StringTrim(),
                ))
                ->setAttribs(Array("size" => "60", "rows" => "3", "cols" => "10", "class" => "span6", "placeholder" => "Note"));
        $this->addElement($ln_note);
        
        
        $ln_status = $this->createElement('select', 'ln_status')
                ->setRequired(TRUE)
                ->addFilters(array(
                    new Zend_Filter_StringTrim(),
                    new Zend_Filter_StringToLower()
                ))
                ->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => "Please select status")));
        $this->addElement($ln_status);

        $submit = $this->createElement('submit', 'Save')
                ->setAttribs(Array('title' => "Save changes", 'class' => "btn-glow primary"));
        $this->addElement($submit);

        $reset = $this->createElement('reset', 'Reset')
                ->setAttribs(Array('title' => "Save changes and continue to edit", 'class' => "btn-glow primary"));
        $this->addElement($reset);
    }

}